# Archlive <http://archlive-pkg.googlecode.com>

pkgname=wine-git
pkgver=20090831
pkgrel=1
pkgdesc="Interpreter for the Windows 3.x and Win32 APIs, with Chinese patches, font AA patches... 包含中文补丁，魔兽全屏补丁，保存地图补丁，局域网补丁，字体AA补丁，wine程序调用浏览器直接调用linux下浏览器"
# 非常感谢jarryson 搜集的补丁
url="http://www.winehq.com/"
arch=('i686' 'x86_64')
license=('LGPL')

depends=('alsa-lib' 'dbus' 'gcc-libs' 'fontconfig' 'freeglut' 'freetype2' 'gtk2' 'lcms' 'libcups' 'libgl' \
	'libice' 'libjpeg' 'libldap' 'libpng' 'libsasl' 'libsm' 'libusb' 'libx11' 'libxau' 'libxcomposite' 'libxcursor' \
	'libxdamage' 'libxext' 'libxi' 'libxinerama' 'libxml2' 'libxrandr' 'libxrender' 'libxslt' 	'libxt' 'libxtst' 'libxv' \
	'libxxf86vm' 'mesa'	'ncurses' 'openssl' 'libxxf86dga' 'openldap'  'pkgconfig' 'sane' 'xproto' 'giflib' 'isdn4k-utils' 'flex'
)

[[ "${CARCH}" == 'x86_64' ]] && 
depends=('lib32-alsa-lib' 'lib32-dbus' 'lib32-gcc-libs'  'lib32-fontconfig' 'lib32-freeglut' 'lib32-freetype2' \
	'lib32-gtk2' 'lib32-lcms'  'lib32-libcups' 'lib32-libgl' 'lib32-libice' 'lib32-libjpeg' 'lib32-libldap' 'lib32-libpng'\
	'lib32-libsasl' 'lib32-libsm' 'lib32-libusb' 'lib32-libx11' 'lib32-libxau' 'lib32-libxcomposite' 'lib32-libxcursor'\
	'lib32-libxdamage' 'lib32-libxext' 'lib32-libxi' 'lib32-libxinerama' 'lib32-libxml2' 'lib32-libxrandr' 'lib32-libxrender'\
	'lib32-libxslt' 'lib32-libxt' 'lib32-libxtst' 'lib32-libxv' 'lib32-libxxf86vm' 'lib32-mesa' 'lib32-ncurses' 'lib32-openssl' \
	'libxxf86dga' 'openldap' 'pkgconfig' 'sane' 'xproto' 'giflib' 'isdn4k-utils'
)

makedepends=('git' 'fakeroot' 'make' 'pkgconfig')
conflicts=('bin32-wine' 'bin32-wine-suse' 'bin32-wine-war' 'wine' 'wine-git')
replaces=()
provides=("wine-git=$pkgver" "wine")
backup=()
source=()
md5sums=()

_gitroot="git://source.winehq.org/git/wine.git"
_gitname="wine"

apatch(){
  for i in ${startdir}/{wine_ch+aa,w3_hosting,w3_minimize,saves,secur32-Disable-schannel-InitializeSecurityContextW}.patch
  do 
      msg2 "adding `basename $i`"
      patch -Np1 -i $i || return 1
  done  
  msg2 "replace iexplore with host broswer.."
  cp ${startdir}/iexplore.c ${srcdir}/$_gitname-build/programs/iexplore || return 1
}
build() {

  cd ${srcdir}
  msg "Connecting to GIT server...."

  if [ -d ${srcdir}/$_gitname ] ; then
    cd $_gitname && git pull origin
    msg "Local repository updated."
  else
    git clone $_gitroot $_gitname
  fi
  msg "GIT checkout done or server timeout"

  msg "Removing old build directory..."
  [ -d ${srcdir}/$_gitname-build ] && rm -Irf ${srcdir}/$_gitname-build

  msg "Creating new build directory..."
  cp -r ${srcdir}/$_gitname ${srcdir}/$_gitname-build

  cd ${srcdir}/$_gitname-build

  msg "Applying patches..." 
  apatch

  msg "Starting make..."
  ./configure --verbose --prefix=/usr --with-x
  make || return 1
  make DESTDIR=${pkgdir} install || return 1
  find ${pkgdir} -type f -name '*.la' -exec rm {} \;
}
